Chapter 15: Blender Bonuses

By Roland Hess

Blenders functionality goes way beyond what has been shown in this book. Youve no doubt seen a lot of buttons that were never touched in the tutorials, and settings that were not explained in the discussions. In addition, there are entire sections of Blender that we havent even mentioned. Just to give you a sense of what to tackle after youve mastered the basics, here is a brief look at some of those items.

Rigid Body Dynamics: Bullet

A rigid body dynamics simulation environment lets you create setups of solid objects and have the system treat them as though they were real objects, conforming to the laws of physics. Rigid body dynamics can simulate something as simple as a brick wall breaking to pieces, or something more elaborate like a complicated Rube Goldberg device. Blender has built in support for rigid body dynamics simulation using the Bullet Physics SDK (Software Development Kit).

This is mainly used to support a Game Engine. Through the use of built in programming tools and internal logic and control systems, you can create a fully-functional game directly within Blender. A game could be a complex racing simulation like Club SILO from Luma studio (http://luma.co.za), or a ball that you push around a maze. Within any game, though, the Bullet physics engine is at work behind the scenes, making things happen in an efficient, realistic manner.

Even if you dont want to create games, though, Bullet is useful to the animator and still artist. Many times, you need an added touch of realism, mostly where gravity and collision are concerned, and it can be tough to keyframe such things believably. In Blender, you can use the rigid body dynamics of Bullet to do the heavy lifting.

Record Game Physics to Ipo

Blender can record Bullet rigid body simulations into an objects animation curves. On the main header is a Game menu, under which you will find the option Record Game Physics to IPO. By enabling this setting, the game engine will bake the locations and rotations of any dynamic physics objects into animation Ipos that can be played back later as a standard animation.

A Basic Rigid Body Sample

On the included disk in the examples folder is a file called PhysicsAnimationBakingDemo.blend. Open this file, position the mouse inside the 3D view and press the P-key to start the Game Engine. After a while, press the Esc-key to stop the simulation, and the newly generated Ipo curves should be visible inside the Ipo view.

Figure BB.01: The Physics Baking Demo

Rigid Body Settings

Objects are identified for use by the physics engine as Static objects by enabling their Actor button in the Logic buttons. Static objects are useful to represent environments in a simulation: the ground, buildings and other non-movable objects. If objects need to be moved by the physics engine, the Dynamic and Rigid Body buttons must also be enabled.

Figure BB.02: The Logic buttons.

Collisions

Any objects that have their Actor button enabled are detectable for collisions. Objects that collide with other objects will react as they would in the real world, knocking each other around based on their mass settings and momentum. Blender 2.43 added support for compound collision shapes for rigid body objects that are part of a parent-child hierarchy. You can enable compound objects by choosing the new Compound button for the parent objects:

Figure BB.03: Compound collision objects.

Compound collision objects let you build complicated structures, with each part having its own type of collision boundaries.

Rigid Body Constraints

Some objects may be dynamic rigid bodies, but their movements should be limited. For example, a door can normally only rotate around its hinges. This hinge would be a constraint. To simulate a chain of connected objects, you can limit the motion of each part in the chain so that the objects stay within a certain distance of one another. These types of constraint relationships are built with the Rigid Body constraint type, in the Object buttons.

Figure BB.04: Rigid Body Constraints

More About Rigid Body Physics and Bullet

You are invited to visit http://www.bulletphysics.com for some cool demos, and lots more information.

COLLADA Physics Support

Several other 3D tools and game engines support COLLADA, an open interchange format for interactive 3D. One of the unique features of COLLADA is its capability to represent rigid body information. Blender 2.42 and later supports COLLADA Physics import and export. This means that the rigid body information that has been set up can be exported and imported through COLLADA 1.4. This can be useful when authoring rigid body data for external game engines like Ogre 3D and C4.

Soft Body Dynamics

Blender has another physics simulator, one for working with soft bodies. Think of gelatin wiggling on a moving plate, a banner flapping in the wind, or the bounce of body fat as a character jumps across a landscape.

A mesh object is set to use Soft Body dynamics by enabling the Soft Body button on the Soft Body panel of the Physics buttons, where the Particle controls are found.

Figure BB.05: The Soft Body controls

If you load the file softbellyhank.blend from the examples folder on the included disk, you will find that Hank from the character animation and rigging chapters has put on a few pounds. Soft body dynamics have been applied to his enlarged stomach so that it rebounds as he walks.

Figure BB.06: Soft belly Hank

Soft bodies work with the concepts of goals and springs. In short, the goal is the original, modeled shape of the mesh, and the Goal controls on the panel tell the simulator how rigorously the mesh should attempt to meet that goal shape. The Edge controls at the bottom of the panel control stretchiness, or how and how much the edges of the mesh can act as springs and stretch as they go about their soft body business.

In the case of Soft Belly Hank, only the stomach is affected by the soft body system. This is because soft bodies can be restricted based on a vertex group. By creating a vertex group with a low weight on the stomach and a high weight on the rest of the mesh, the soft body system can be told to use those vertex group weights for goals.

Soft bodies can also be used to simulate cloth, although at this time a full cloth simulation for something like an animated characters clothes isnt practical.

In addition to the basic soft body simulations, the system can take colliding objects into account, as well as check for self-collision within a soft body object to keep it from intersecting itself. Standard and self-collision detection add another level of realism to the soft body simulator.

Fluid Simulation

In addition to rigid and soft body physics, Blender has an integrated fluid simulator. Based on the Lattice-Boltzmann Method, the fluid system produces excellent results that are limited only by the computational strength (RAM and CPU) of your particular machine.

A fluid simulation requires several components: a domain (the area within which the simulation takes place), a fluid (a mesh that defines the starting shape and location of the fluid) and obstacle objects. You can also include objects that will add fluid to the simulation over time (inflows) or remove it (outflows). These are all defined by adding separate objects to your scene, then enabling each for fluids on the Fluid Simulation panel of the Physics buttons. From there, you use the buttons to define which role the object will play in the simulation.

Figure BB.07: The Fluid Simulation assignment buttons.

After all of the objects are defined, the simulation is run by pressing the Bake button. Using high resolutions can take enormous amounts of time and memory, but most modern systems should be able to handle small-scale needs like water pouring into a glass, etc., without much trouble.

The final product of the fluid simulation is an animated mesh object that can use any standard Blender material, with careful settings to mimic water or other fluids producing excellent visual results.

Figure BB.08, .09: Some examples of Blender's fluid simulator, courtesy of Mike Pan.

Creating your own fluid simulation is simple.

Start a new scene, select the default cube and Enable it as a Domain in the Fluid Simulation buttons.

Figure BB.18: Click Enable, then Domain.

Add an Icosphere, positioning it within the cube and scaling it down to fit completely inside. Then, Enable the sphere as the Fluid.

Figure BB.19: The icosphere inside the cube, Enabled as a Fluid.

One thing to be aware of before you actually do any simulation is that the Domain object, in addition to defining the area in which the simulation takes place, becomes the actual animated fluid. Dont be surprised when you see your nice fluid sim, but your Domain object is gone. The Domain object is the fluid sim.

In a timeline (or Render buttons) window, set the animation End frame to 75 or so. Reselect the cube and click "Bake" on the Fluid Simulation panel. Wait a couple of minutes. The progress bar on the main header will show how far the simulation has progressed. It will also show itself working in the 3D view. When it's done, just press Alt-A in the 3D view to see the simulation. For a better look with higher resolution data, you can change the dropdown menu that reads "Preview" to "Final."

If you fluid simulation is taking too long to calculate, you can press the Esc-key to cancel.

Python Scripting

Blender includes a programming language called Python. By writing or loading Python programs within Blender's text editor, you can extend Blender's functionality in almost any way you can imagine.

A simple script to select an object's parent looks like this:

Figure BB.11: [no text]

Of course, you don't have to be a programmer to take advantage of the creativity of others. Tucked away inside several of Blender's menus are Python scripts, ready to use. In fact, you may have already used them without knowing it. Here are some of the places you can find them:

Figure BB.12, .13, .14, .15: [no text]

The last image shows one of the UV Mapping pop-up menus, where the last item "Unwrap (smart projections)" is a Python script. In the other menus, you can see the little Python snake icon beside the entries. Each and every one of those is a Python script that is loaded and placed in the menus when Blender runs.

In addition to being integrated into the menu system, Python scripts can be executed in a number of different ways. If they are loaded as a text file like the first example, placing the mouse over the text window and pressing Alt-P will run the script. Scripts in the text editor can also be linked to scenes, materials and objects in the 3D view. Such linked scripts can be set to run whenever the screen redraws, whenever the frame number changes, or at render time. This kind of link gives scripts the ability to control and alter objects in real-time as you work, over the course of an animation, or just during the render.

Figure BB.16: A script called "MakeMonster" linked to a selected object, and set to update every time the frame number changes.

Some of the more complex Python scripts can do things like create an entire system for exporting to and driving Renderman compliant renderers, or simulate crowd motion with full character animation.

Figure BB.17, .20: The Neqsus Renderman exporter (courtesy of Bobby Parker), and BlenderPeople crowd simulation.

Although a Blender installation comes with a Python interpreter built in, if you have the full Python programming language installed on your system already, Blender's Python environment will happily use your installation, including any special modules or packages you have installed. This means that your capabilities with Python scripting in Blender are almost limitless. Future development plans for Python within Blender include the ability for Python scripts to create and control their own UI panels directly within the main Blender interface.

Coming Soon!

With an active and creative development team, there are even better things on the horizon.

Currently in the works:

- The ability to remap hotkeys and control events, meaning that users can truly customize their own experience. Keyboard maps that simulate other 3D applications to ease transitioning users will no doubt become popular.

- A completely new particle system with excellent support for hair and fur that includes intuitive, interactive controls for combing, growing and cutting hair, as well as a host of new methods of particle visualization and control.

- The next Google Summer of Code will no doubt include several great Blender projects. In the past, the GSoC has brought us the modifier stack enhancements, multiresolution sculpting, FFMPEG, the IK rewrite and improvements, and the fluid simulator.

BLENDER OPEN CONTENT LICENSE 

 Terms and Conditions for Copying, Distributing, and Modifying 

 Items other than copying, distributing, and modifying the  Content with which this license was distributed (such as using,  etc.) are outside the scope of this license. 

 1. You may copy and distribute exact replicas of the OpenContent (OC) as you receive it, in any medium, provided that you conspicuously and  appropriately publish on each copy an appropriate copyright notice and  disclaimer of warranty; keep intact all the notices that refer to this  License and to the absence of any warranty; and give any other recipients of the OC a copy of this License along with the OC. You may  at your option charge a fee for the media and/or handling involved in  creating a unique copy of the OC for use offline, you may at your option offer instructional support for the OC in exchange for a fee, or you may at your option offer warranty in exchange for a fee. You may not charge a fee for the OC itself. You may not charge a fee for the sole service of  providing access to and/or use of the OC via a network (e.g. the  Internet), whether it be via the world wide web, FTP, or any other  method. 

 2. You may modify your copy or copies of the OpenContent or any portion  of it, thus forming works based on the Content, and distribute  such modifications or work under the terms of Section 1 above, provided  that you also meet all of these conditions:  

  a) You must cause the modified content to carry prominent notices stating that you changed it, the exact nature and content of the changes, and the date of any change.  

  b) You must cause any work that you distribute or publish, that in whole  or in part contains or is derived from the OC or any part thereof, to be  licensed as a whole at no charge to all third parties under the terms of this License, unless otherwise permitted under applicable Fair Use law. 

  c) The name of the Copyright Holder or contributors to the OC may not be used to endorse or promote products derived from this software without specific prior written permission.

 These requirements apply to the modified work as a whole. If  identifiable sections of that work are not derived from the OC, and can  be reasonably considered independent and separate works in themselves,  then this License, and its terms, do not apply to those sections when  you distribute them as separate works. But when you distribute the same  sections as part of a whole which is a work based on the OC, the  distribution of the whole must be on the terms of this License, whose  permissions for other licensees extend to the entire whole, and thus to  each and every part regardless of who wrote it. Exceptions are made to this requirement to release modified works free of charge under this  license only in compliance with Fair Use law where applicable. 

 3. You are not required to accept this License, since you have not  signed it. However, nothing else grants you permission to copy,  distribute or modify the OC. These actions are prohibited by law if you  do not accept this License. Therefore, by distributing or translating  the OC, or by deriving works herefrom, you indicate your acceptance of  this License to do so, and all its terms and conditions for copying,  distributing or translating the OC.  

 NO WARRANTY 

 4. BECAUSE THE OPENCONTENT (OC) IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE OC, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE OC "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK OF USE OF THE OC IS WITH YOU. SHOULD THE OC PROVE FAULTY, INACCURATE, OR OTHERWISE UNACCEPTABLE  YOU ASSUME THE COST OF ALL NECESSARY REPAIR OR CORRECTION.  

 5. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING  WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MIRROR AND/OR REDISTRIBUTE THE OC AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE OC, EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 

